//
//  XLUserEvaluateCell.m
//  XLPersonCenter
//
//  Created by 宋振 on 2018/7/23.
//  Copyright © 2018年 夜幕繁华. All rights reserved.
//

#import "XLUserEvaluateCell.h"
#import "XLTgLabelView.h"

#import "XLPersonCenterTool.h"
#import "Masonry.h"



@interface XLUserEvaluateCell ()

//标签
@property (nonatomic, strong) XLTgLabelView *  labelView;

@end

@implementation XLUserEvaluateCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        /**
         设置界面显示
         */
        [self setCustomeView];
    }
    
    return self;
}

/**
 设置界面显示
 */
- (void)setCustomeView
{
    //标题
    UILabel *titleLbl = [[UILabel alloc] init];
    titleLbl.textColor = [UIColor colorWithRed:17/255.0 green:17/255.0 blue:17/255.0 alpha:1];
    titleLbl.font = [UIFont systemFontOfSize:kScale(13)];
    titleLbl.text = @"用户评价";
    [self.contentView addSubview:titleLbl];
    
    [titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(kScale(15));
        make.top.equalTo(self.mas_top).offset(kScale(15));
        make.height.mas_equalTo(kScale(18));
    }];
    
    
    //temp 临时测试数据
    NSMutableArray *array = [NSMutableArray arrayWithCapacity:1];
    
    //创建标签
    self.labelView = [[XLTgLabelView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 173) andLabelArray:array];
    
//    self.labelView = [[XLTgLabelView alloc] init];
    
    //重新更新frame 因为有可能高度不匹配 需要从真实数据中得到高度
//    CGFloat height = [self.labelView getViewHeight];
//    CGRect rect = CGRectMake(0, 15, self.bounds.size.width, height);
//    self.labelView.frame = rect;
    
    [self.labelView layoutIfNeeded];
    
    [self addSubview:self.labelView];
    
    [self.labelView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLbl.mas_bottom).offset(kScale(15));
        make.left.right.equalTo(self);
        make.bottom.equalTo(self.mas_bottom);
    }];
    
}


#pragma mark    - - - Method - - -

//获取cell高度
- (CGFloat)getCellHeight
{
    [self layoutIfNeeded];
    
    [self layoutSubviews];
    
    CGFloat labelHeight = [self.labelView getViewHeight];
    
    
    
    CGFloat height = labelHeight + 55.0;
//    self.labelView.frame.origin.y + self.labelView.bounds.size.height+25;
    
    return height;
}





#pragma mark    -   -   - 懒加载 - -   -





- (void)setDataSources:(NSArray *)dataSources
{
    _dataSources = dataSources;
    
    NSMutableArray *tempArray = [NSMutableArray arrayWithArray:dataSources];
    
    self.labelView.labelArray = [tempArray mutableCopy];
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
